home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _1B92F97993D440A685E744E052B0F50A < prev    next >
Encoding:
Text File  |  2004-01-06  |  7.4 KB  |  205 lines

  1. --------------------------------------------------
  2. --   Created By: Petar
  3. --   Description: This behaviour activates as a response to an island-wide alarm call, or in response to a group death
  4. --------------------------------------------------
  5. --   last modified by: sten 23-10-2002
  6.  
  7. AIBehaviour.CoverAlert = {
  8.     Name = "CoverAlert",
  9.  
  10.         
  11.     ---------------------------------------------
  12.     OnNoTarget = function( self, entity )
  13.         -- called when the enemy stops having an attention target
  14.         entity:SelectPipe(0,"search_for_target");
  15.     end,
  16.     ---------------------------------------------
  17.     OnPlayerSeen = function( self, entity, fDistance )
  18.         -- called when the enemy sees a living player
  19.         -- REVIEWED
  20.  
  21.  
  22.         entity:Readibility("ENEMY_TARGET_REGAIN");
  23.         if (AI:GetGroupCount(entity.id) > 1) then
  24.             -- only send this signal if you are not alone
  25.             AI:Signal(SIGNALFILTER_SUPERGROUP, 1, "wakeup",entity.id);
  26.             AI:Signal(SIGNALFILTER_SUPERGROUP, 1, "HEADS_UP_GUYS",entity.id);
  27.     
  28.             entity:SelectPipe(0,"cover_scramble_beacon");
  29.         else
  30.  
  31.  
  32.             -- you are on your own
  33.             entity:SelectPipe(0,"cover_scramble");
  34.         end
  35.  
  36.         if (entity.RunToTrigger == nil) then
  37.             entity:RunToAlarm();
  38.         end    
  39.         
  40.     end,
  41.     ---------------------------------------------
  42.     OnEnemyMemory = function( self, entity )
  43.         -- called when the enemy can no longer see its foe, but remembers where it saw it last
  44.     end,
  45.     ---------------------------------------------
  46.     OnInterestingSoundHeard = function( self, entity )
  47.         -- called when the enemy hears an interesting sound
  48.         entity:SelectPipe(0,"cover_look_closer");
  49.          entity:InsertSubpipe(0,"DropBeaconAt"); 
  50.     end,
  51.     ---------------------------------------------
  52.     OnThreateningSoundHeard = function( self, entity, fDistance )
  53.         entity:MakeAlerted();
  54.  
  55.         entity:SelectPipe(0,"cover_investigate_threat"); 
  56.  
  57.  
  58.  
  59.         if (fDistance > 20) then 
  60.             entity:InsertSubpipe(0,"do_it_running");
  61.         else
  62.             entity:InsertSubpipe(0,"do_it_walking");
  63.         end
  64.  
  65.         entity:InsertSubpipe(0,"cover_threatened"); 
  66.     end,
  67.     ---------------------------------------------
  68.     OnReload = function( self, entity )
  69.         -- called when the enemy goes into automatic reload after its clip is empty
  70.         entity:SelectPipe(0,"cover_scramble");
  71.     end,
  72.     ---------------------------------------------
  73.     OnNoHidingPlace = function( self, entity, sender )
  74.     end,    
  75.     --------------------------------------------------
  76.     OnNoFormationPoint = function ( self, entity, sender)
  77.         -- called when the enemy found no formation point
  78.     end,
  79.     ---------------------------------------------
  80.     OnReceivingDamage = function ( self, entity, sender)
  81.         -- called when the enemy is damaged
  82.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  83.         entity:Readibility("GETTING_SHOT_AT",1);
  84.         entity:SelectPipe(0,"getting_shot_at");
  85.     end,
  86.     --------------------------------------------------
  87.     OnBulletRain = function ( self, entity, sender)
  88.         -- called when the enemy detects bullet trails around him
  89.     end,
  90.     --------------------------------------------------
  91.     -- CUSTOM SIGNALS
  92.     --------------------------------------------------
  93.  
  94.     INVESTIGATE_TARGET = function (self, entity, sender)
  95.         entity:SelectPipe(0,"cover_investigate_threat");        
  96.     end,
  97.     ---------------------------------------------    
  98.  
  99.  
  100.     OnGroupMemberDied = function( self, entity, sender)
  101.         -- called when a member of the group dies
  102.         
  103.          if (sender.groupid == entity.groupid) then
  104.              if (entity ~= sender) then
  105.                  entity:SelectPipe(0,"TeamMemberDiedLook");
  106.              end
  107.          else
  108.              entity:SelectPipe(0,"randomhide");
  109.          end
  110.     end,
  111.     --------------------------------------------------
  112.     OnGroupMemberDiedNearest = function ( self, entity, sender)
  113.  
  114.         AIBehaviour.DEFAULT:OnGroupMemberDiedNearest(entity,sender);
  115.  
  116.         entity:SelectPipe(0,"TeamMemberDiedBeaconGoOn",sender.id);
  117.     end,
  118.     ---------------------------------------------
  119.     Cease = function( self, entity, fDistance )
  120.         entity:SelectPipe(0,"cover_cease_approach"); -- in PipeManagerShared.lua             
  121.     end,
  122.     ---------------------------------------------
  123.     TRY_TO_LOCATE_SOURCE = function (self, entity, sender)
  124.         entity:SelectPipe(0,"basic_lookingaround");
  125.     end,
  126.     ---------------------------------------------
  127.     DEATH_CONFIRMED = function (self, entity, sender)
  128.         --System:LogToConsole(entity:GetName().." recieved DEATH_CONFIRMED command in CoverAlert");
  129.         entity:SelectPipe(0,"ChooseManner");
  130.     end,
  131.     ---------------------------------------------
  132.     ChooseManner = function (self, entity, sender)
  133.         --System:LogToConsole("### ChooseManner ###");
  134.         local XRandom = random(1,3);
  135.         if (XRandom == 1) then
  136.             entity:InsertSubpipe(0,"LookForThreat");            
  137.         elseif (XRandom == 2) then
  138.             entity:InsertSubpipe(0,"RandomSearch");            
  139.         elseif (XRandom == 3) then
  140.             entity:InsertSubpipe(0,"ApproachDeadBeacon");
  141.         end
  142.     end,
  143.     --------------------------------------------------
  144.     -- GROUP SIGNALS
  145.     --------------------------------------------------
  146.     INCOMING_FIRE = function (self, entity, sender)
  147.         if (entity ~= sender) then
  148.             entity:SelectPipe(0,"randomhide");
  149.         end
  150.     end,
  151.     ---------------------------------------------    
  152.     KEEP_FORMATION = function (self, entity, sender)
  153.         -- the team leader wants everyone to keep formation
  154.     end,
  155.     ---------------------------------------------    
  156.     SINGLE_GO = function (self, entity, sender)
  157.         -- the team leader has instructed this group member to approach the enemy
  158.     end,
  159.     ---------------------------------------------    
  160.     GROUP_COVER = function (self, entity, sender)
  161.         -- the team leader has instructed this group member to cover his friends
  162.     end,
  163.     ---------------------------------------------    
  164.     IN_POSITION = function (self, entity, sender)
  165.         -- some member of the group is safely in position
  166.     end,
  167.     ---------------------------------------------    
  168.     GROUP_SPLIT = function (self, entity, sender)
  169.         -- team leader instructs group to split
  170.     end,
  171.     ---------------------------------------------    
  172.     PHASE_RED_ATTACK = function (self, entity, sender)
  173.         -- team leader instructs red team to attack
  174.     end,
  175.     ---------------------------------------------    
  176.     PHASE_BLACK_ATTACK = function (self, entity, sender)
  177.         -- team leader instructs black team to attack
  178.     end,
  179.     ---------------------------------------------    
  180.     GROUP_MERGE = function (self, entity, sender)
  181.         -- team leader instructs groups to merge into a team again
  182.     end,
  183.     ---------------------------------------------    
  184.     CLOSE_IN_PHASE = function (self, entity, sender)
  185.         -- team leader instructs groups to initiate part one of assault fire maneuver
  186.     end,
  187.     ---------------------------------------------    
  188.     ASSAULT_PHASE = function (self, entity, sender)
  189.         -- team leader instructs groups to initiate part one of assault fire maneuver
  190.     end,
  191.     ---------------------------------------------    
  192.     GROUP_NEUTRALISED = function (self, entity, sender)
  193.         -- team leader instructs groups to initiate part one of assault fire maneuver
  194.     end,
  195.     ------------------------------------------------------------------------
  196.     ------------------------------ Animation -------------------------------
  197.     target_lost_animation = function (self, entity, sender)
  198.         entity:StartAnimation(0,"enemy_target_lost",0);
  199.     end,
  200.     ------------------------------------------------------------------------
  201.     confused_animation = function (self, entity, sender)
  202.         entity:StartAnimation(0,"_headscratch1",0);
  203.     end,
  204.     ------------------------------------------------------------------------
  205. }